<%@page import="java.text.DecimalFormat"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<c:set var="source" value="createTournament" />
<c:set var="noSubheader" value="noSubheader" />
<c:set var="createTournament" value="true"></c:set>
<c:set var="editTournament" value="false"></c:set>
<c:if test="${not empty tournamentId}"> 
<%-- <c:set var="source" value="myTournaments" /> --%>
<c:set var="noSubheader" value="" />
<c:set var="createTournament" value="false"></c:set>
<c:set var="editTournament" value="true"></c:set>
</c:if>

<%-- <jsp:include page="/headerNew.htm" flush="true">
<jsp:param name="source" value="${source}" />
</jsp:include> --%>


<link type="text/css" rel="stylesheet" href="${cdnPath}/v/${conf.CSS_CACHE_VERSION}/booking/includes/courtMgm.css?v=${conf.CSS_CACHE_VERSION}" />
<link type="text/css" rel="stylesheet"
href="${cdnPath}/v/${conf.CSS_CACHE_VERSION}/tms/includes/tms.css?v=${conf.CSS_CACHE_VERSION}" />
<link type="text/css" rel="stylesheet"
href="${cdnPath}/v/${conf.CSS_CACHE_VERSION}/includes_new/ui.theme.css" />
<link type="text/css" rel="stylesheet"
href="${cdnPath}/v/${conf.CSS_CACHE_VERSION}/includes_new/ui.datepicker.css" />

<script type="text/javascript"
src="${cdnPath}/v/${conf.JS_CACHE_VERSION}/scripts_new/jquery.ui.core.js"></script>
<script type="text/javascript" src="${cdnPath}/v/${conf.JS_CACHE_VERSION}/scripts_new/ui.datepicker.js"></script>
<script type="text/javascript" src="${cdnPath}/v/${conf.JS_CACHE_VERSION}/tms/scripts/createTournament.js"></script>
<script type="text/javascript" src="${cdnPath}/v/${conf.JS_CACHE_VERSION}/course/scripts/course.js?v=${conf.JS_CACHE_VERSION}"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.8.1/jquery.validate.js"></script>	
<script type="text/javascript" src="${cdnPath}/v/${conf.JS_CACHE_VERSION}/scripts_new/jquery-googleMapsNew.js?v=${conf.JS_CACHE_VERSION}"></script>
<script type="text/javascript">
var map = null;
var markers = [];
var geocoder = getGeocoder();
var bounds = new google.maps.LatLngBounds();

var sidebarHtml = '';
var clubIconImg = '/images/location-marker-blue.png';
var clubDetails = '<div style="width:150px;">';
if('${club.url}' != '') {
clubDetails += '<a target="_blank" href="${fn:replace(club.url, replace, replaceWith)}" style="font-weight:bold;">${fn:replace(club.name, replace, replaceWith)}: New Position</a>';
} else {
clubDetails += '<span style="font-weight:bold;">${fn:replace(club.name, replace, replaceWith)}: New Position</span>';
}
clubDetails += '<br />${address}</div>';

function openMarkerInfoWindow(i) {
if(map != null) {
if(openedInfoWindow) {
openedInfoWindow.close();
}
markers[i].infowindow.open(map, markers[i]);
openedInfoWindow = markers[i].infowindow;
}
}

function addMovableMarker(latlng) {
$('#suggest').html('');
try {
removeMarker(markers[1]);
} catch(e) {}

var markerOptions = {iconImg: clubIconImg, draggable: true, infoWindowHtml: clubDetails, latInput: 'latitude', lngInput: 'longitude'};
markers[1] = getLatLngMarker(map, latlng, markerOptions);
$('#latitude').val(latlng.lat()).change();
$('#longitude').val(latlng.lng()).change();
bounds.extend(latlng);
/*	 if (bounds.getNorthEast().equals(bounds.getSouthWest())) {
var extendPoint1 = new google.maps.LatLng(bounds.getNorthEast().lat() + 0.01, bounds.getNorthEast().lng() + 0.01);
var extendPoint2 = new google.maps.LatLng(bounds.getNorthEast().lat() - 0.01, bounds.getNorthEast().lng() - 0.01);
bounds.extend(extendPoint1);
bounds.extend(extendPoint2);
} */
map.fitBounds(bounds);
$('#newPosImg').html('<img border="0" src="' + clubIconImg + '" onclick="openMarkerInfoWindow(1)" style="cursor:pointer;" alt="${fn:replace(club.name, replace, replaceWith)}" />');
$('#newPosTxt').html('<a style="text-decoration:none;font-weight:bold;" href="javascript:openMarkerInfoWindow(1)">${fn:replace(club.name, replace, replaceWith)}: New Position</a><br /><a target="_blank" href="${conf.TE_HOME}/' + ('${club.shortName}' != '' ? 'club/${club.shortName}' : 'clubs/details.htm?clubId=${club.clubId}') + '"><img border="0" src="${cdnPath}/images/rightarrow.gif" alt="More" />&nbsp;more info</a>');
}

function searchAddress() {
$('#suggest').html('');
var address = $('#address').val();
if(geocoder && address != '') {
try {
removeMarker(markers[1]);
} catch(e) {}

$('#latitude').val('').change();
$('#longitude').val('').change();
google.maps.event.addListener(map, 'click', function(event) {
addMovableMarker(event.latLng);
});
$('#newPosImg').html('<img border="0" src="' + clubIconImg + '" alt="${fn:replace(club.name, replace, replaceWith)}" />');
$('#newPosTxt').html('<span style="font-weight:bold;">${fn:replace(club.name, replace, replaceWith)}: New Position</span><br /><a target="_blank" href="${conf.TE_HOME}/' + ('${club.shortName}' != '' ? 'club/${club.shortName}' : 'clubs/details.htm?clubId=${club.clubId}') + '"><img border="0" src="${cdnPath}/images/rightarrow.gif" alt="More" />&nbsp;more info</a>');

var suggestOptions = {suggestDiv: 'suggest', suggestCallback: 'addMarker', suggestErrMessage: '<span style="color:#f8081e;">Given address could not be located. Please check the address.</span>'};
getLatLng(geocoder, address, function(latlng) {
if(latlng) {
addMovableMarker(latlng);
}
}, suggestOptions);
}
}

function addMarker(lat, lng) {
var latlng = new google.maps.LatLng(lat, lng);
if(latlng) {
addMovableMarker(latlng);
}
}

function markerCallback(latlng) {
if(latlng) {
addMovableMarker(latlng);
$('#newPosImg').html('<img border="0" src="' + clubIconImg + '" onclick="openMarkerInfoWindow(1)" style="cursor:pointer;" alt="${fn:replace(club.name, replace, replaceWith)}" />');
$('#newPosTxt').html('<a style="text-decoration:none;font-weight:bold;" href="javascript:openMarkerInfoWindow(1)">${fn:replace(club.name, replace, replaceWith)}: New Position</a><br /><a target="_blank" href="${conf.TE_HOME}/' + ('${club.shortName}' != '' ? 'club/${club.shortName}' : 'clubs/details.htm?clubId=${club.clubId}') + '"><img border="0" src="${cdnPath}/images/rightarrow.gif" alt="More" />&nbsp;more info</a>');
} else {
$('#newPosImg').html('<img border="0" src="' + clubIconImg + '" alt="${fn:replace(club.name, replace, replaceWith)}" />');
$('#newPosTxt').html('<span style="font-weight:bold;">${fn:replace(club.name, replace, replaceWith)}}: New Position</span><br /><a target="_blank" href="${conf.TE_HOME}/' + ('${club.shortName}' != '' ? 'club/${club.shortName}' : 'clubs/details.htm?clubId=${club.clubId}') + '"><img border="0" src="${cdnPath}/images/rightarrow.gif" alt="More" />&nbsp;more info</a>');
}
}

function markerCallbackLoop(latlng, club, details, count, listSize, i) {
iconImg = 'http://maps.gstatic.com/intl/en_ALL/mapfiles/marker' + mapLettersArr[count++] + '.png';
if(latlng) {
markerOptions = {iconImg: iconImg, infoWindowHtml: details};
try {
removeMarker(markers[i]);
} catch(e) {}

markers[i] = getLatLngMarker(map, latlng, markerOptions);
bounds.extend(latlng);
map.setZoom(5);
sidebarHtml += '<tr><td style="border:0;"><img border="0" src="' + iconImg + '" onclick="openMarkerInfoWindow(' + i + ')" style="cursor:pointer;" alt="' + club.name + '" /></td><td style="border:0;"><a style="text-decoration:none;font-weight:bold;" href="javascript:openMarkerInfoWindow(' + i + ')">' + club.name + '</a><br /><a target="_blank" href="${conf.TE_HOME}' + club['details_${conf.DISALLOWED_URL_NAME}'] + '"><img border="0" src="${cdnPath}/images/rightarrow.gif" />&nbsp;more info</a></td></tr>';
} else {
sidebarHtml += '<tr><td style="border:0;"><img border="0" src="' + iconImg + '" alt="' + club.name + '" /></td><td style="border:0;"><span style="text-decoration:none;font-weight:bold;">' + club.name + ': Cannot Locate</span><br /><a target="_blank" href="${conf.TE_HOME}' + club['details_${conf.DISALLOWED_URL_NAME}'] + '"><img border="0" src="${cdnPath}/images/rightarrow.gif" />&nbsp;more info</a></td></tr>';
}
displaySidebar(listSize, i);
}

function displaySidebar(listSize, i) {
if(listSize == i - 1) {
$('#map_sidebar').append(sidebarHtml);
map.fitBounds(bounds);

}		
}

$(function() {
map = getMap('map', 2, google.maps.MapTypeId.SATELLITE);
google.maps.event.addListener(map, 'click', function(event) {
addMovableMarker(event.latLng);
});

var iconImg;
var latlng;
var markerOptions;
if('${club.latitude}' != '' && '${club.longitude}' != '') {
iconImg = 'http://maps.gstatic.com/intl/en_ALL/mapfiles/marker.png';
latlng = new google.maps.LatLng('${club.latitude}', '${club.longitude}');
if(latlng) {
var details = '<div style="width:150px;">';
if('${club.url}' != '') {
details += '<a target="_blank" href="${fn:replace(club.url, replace, replaceWith)}" style="font-weight:bold;">${fn:replace(club.name, replace, replaceWith)}: Old Position</a>';
} else {
details += '<span style="font-weight:bold;">${fn:replace(club.name, replace, replaceWith)}: Old Position</span>';
}
details += '<br />${address}</div>';

markerOptions = {iconImg: iconImg, infoWindowHtml: details};
markers[0] = getLatLngMarker(map, latlng, markerOptions);
bounds.extend(latlng);
$('#oldPosImg').html('<img border="0" src="' + iconImg + '" onclick="openMarkerInfoWindow(0)" style="cursor:pointer;" alt="${fn:replace(club.name, replace, replaceWith)}" />');
$('#oldPosTxt').html('<a style="text-decoration:none;font-weight:bold;" href="javascript:openMarkerInfoWindow(0)">${fn:replace(club.name, replace, replaceWith)}: Old Position</a><br /><a target="_blank" href="${conf.TE_HOME}/' + ('${club.shortName}' != '' ? 'club/${club.shortName}' : 'clubs/details.htm?clubId=${club.clubId}') + '"><img border="0" src="${cdnPath}/images/rightarrow.gif" alt="More" />&nbsp;more info</a>');
markerCallback(latlng);
} else {
sidebarHtml += '<tr><td valign="top" style="border:0;"><img border="0" src="' + iconImg + '" alt="${fn:replace(club.name, replace, replaceWith)}" /></td><td style="border:0;"><span style="text-decoration:none;font-weight:bold;">${fn:replace(club.name, replace, replaceWith)}: Old Position (Cannot Locate)</span><br /><a target="_blank" href="${conf.TE_HOME}/' + ('${club.shortName}' != '' ? 'club/${club.shortName}' : 'clubs/details.htm?clubId=${club.clubId}') + '"><img border="0" src="${cdnPath}/images/rightarrow.gif" alt="More" />&nbsp;more info</a></td></tr>';
}
} else {

$.getJSON('/ajax/searchClubs.htm?city=' + encodeURIComponent('${fn:replace(cityState, replace, replaceWith)}') + '&country=${club.countryId}', function(data) {
var clubsList = data.clubs;
var isOnlyCurrentClubInList = true;
if(clubsList.length > 0) {
var count = 2;		// Starting with 2 to start from 'B'
for(var i=0;i<clubsList.length;i++) {
var club = clubsList[i];
if(club.clubId == '${club.clubId}') {
// Current Club already processed
displaySidebar(clubsList.length, i + 2);
continue;
}

isOnlyCurrentClubInList = false;
var address = club.streetAddress;
if(address.length > 0) {
address += ', ';
}
address += $.trim(club.city + ' ' + club.state);
address += ', ' + club.countryName;

var details = '<div style="width:150px;">';
if(club.url != '') {
details += '<a target="_blank" href="' + club['url_${conf.DISALLOWED_URL_NAME}'] + '" style="font-weight:bold;">' + club.name + '</a>';
} else {
details += '<span style="font-weight:bold;">' + club.name + '</span>';
}
details += '<br />' + address + '</div>';

if(club.longitude == '' || club.latitude == '') {
getLatLng(geocoder, address, function(latlng) {
markerCallbackLoop(latlng, club, details, count, clubsList.length, i + 2);	// Positions 0, 1 reserved for current club
});
} else {
markerCallbackLoop(new google.maps.LatLng(club.latitude, club.longitude), club, details, count, clubsList.length, i + 2);	// Positions 0, 1 reserved for current club
}
count++;
}
}
if(isOnlyCurrentClubInList || clubsList.length == 0) {
$('#map_sidebar').append(sidebarHtml);
map.fitBounds(bounds);
}
});

}
var suggestOptions = {suggestDiv: 'suggest', suggestCallback: 'addMarker'};
getLatLng(geocoder, '${address}', function(latlng) {
markerCallback(latlng);
}, suggestOptions);
});
</script>

<script>
jQuery.validator.addMethod("alpha", function(value, element) {
return this.optional(element) || value == value.match(/^[a-zA-Z]+$/);
},"Only Characters Allowed.");

jQuery.validator.addMethod("valueNotEquals", function(value, element, arg){
return arg != value;
}, "Value must not equal arg.");

function chgCurrency(value) {
if (value == 'currency') {
if (document.getElementById('pmode').selectedIndex == 1) //Unlock lstCity
document.getElementById('currency').disabled = true;
else // lock currency
document.getElementById('currency').disabled = false;
}
}

function validateCalendar()
{
var SDate = $("#startDateStr").val();
var EDate = $("#endDateStr").val();

var currency = $("#currencyId").val();
var paymentMode = $("#pmode").val();
var prizeMoney = $("#pmoney").val();

var player1Phone = $("#contact").val();

var isVisible = $('#sliderContainer').is(':visible');
var zipCode = $('#zipCode').val();
var startDate=str2obj(SDate);
var endDate=str2obj(EDate);
var now = new Date();

now.setDate(now.getDate() - 1);


if(SDate == "" || EDate == "" || currency == "currency" || paymentMode == "payMode" || prizeMoney == "prize"){
alertWindow("Please fill the mandatory fields.");
return false;
}

if(startDate < now){
alertWindow("Please ensure that tournament start date should not be past date.");
return false;
}
if(startDate > endDate)
{
alertWindow("Please ensure that the End Date is greater than or equal to the Start Date.");	     	
return false;
}
if (isVisible){	 
alertWindow("Please fill event details or close the previously opend Event details.");  
return false; 
}
if(player1Phone != "" ){
if(!player1Phone.match(/^\d+/))
{
alertWindow("Please enter only numeric characters phone number!");
return false;
}
if(player1Phone.length > 14 || player1Phone.length <8)
{				
alertWindow("Please enter valid phone number!");
return false;
}	
}
document.forms["tmsTournamentView"].submit();
}


function validateTornamentDates(currentVal)
{
var SDate = $("#startDateStr").val();
var EDate = $("#endDateStr").val();

var startDate=str2obj(SDate);
var endDate=str2obj(EDate);
var now = new Date();

now.setDate(now.getDate() - 1);

if(SDate == ""){
alertWindow("Please fill the tournaments start dates before event details");
$(currentVal).val('');
return false;
}

if(EDate == ""){
alertWindow("Please fill the tournaments end dates before event details");
$(currentVal).val('');
return false;
}

if(SDate == "" && EDate == ""){
alertWindow("Please fill the tournaments start and end dates before event details");
$(currentVal).val('');
return false;
}
if(startDate < now){
alertWindow("Please ensure that tournament start date should not be past date.");
$(currentVal).val('');
return false;
}
if(startDate > endDate)
{
alertWindow("Please ensure that the End Date is greater than or equal to the Start Date.");
$(currentVal).val();
return false;
}
return true;
}
function validateLastDtOfFees(lastDateStr,currentVal,eventStartDt,eventEndDt)
{	

var SDate = $("#startDateStr").val();
var EDate = $("#endDateStr").val();

var etStartDt = $(eventStartDt).val();
var etEndDt = $(eventEndDt).val();


var tStartDate = str2obj(SDate);
var tEndDate = str2obj(EDate);
var lastDate = str2obj(lastDateStr);

var eveStartDt = str2obj(etStartDt);
var eveEndDt = str2obj(etEndDt);

var currentDate = new Date();

if(!validateTornamentDates(currentVal)){
$(currentVal).val('');
return false;
}

if(etStartDt == "" || etEndDt == ""){			 
alertWindow("Please fill the event start and end dates before event details");
$(currentVal).val('');
return false;
}

if(lastDate < currentDate){
alertWindow("Please ensure that fee submission date is greater than current date.");
$(currentVal).val('');
return false;
}
/* Commented as per the UAT 8/05/2013 #8. Added confirmation box.
else if(lastDate > eveStartDt){
alertWindow("Please ensure that fee submission date is lesser than event start date.");
$(currentVal).val('');
return false;
}
*/
else if (lastDate > eveStartDt){
confirmWindow('Are you sure to keep \'Last date of Fee submission\' after the event start date?', function() {},function(){$(currentVal).val('');});
return false;
}
return true;
}

function validateLastDtOfEntry(lastDateStr,currentVal,eventStartDt,eventEndDt)
{	

var SDate = $("#startDateStr").val();
var EDate = $("#endDateStr").val();

var etStartDt = $(eventStartDt).val();
var etEndDt = $(eventEndDt).val();


var tStartDate = str2obj(SDate);
var tEndDate = str2obj(EDate);
var lastDate = str2obj(lastDateStr);
var currentDate = new Date();
var eveStartDt = str2obj(etStartDt);
var eveEndDt = str2obj(etEndDt);

if(!validateTornamentDates(currentVal)){
$(currentVal).val('');
return false;
}

if(etStartDt == "" || etEndDt == ""){			 
alertWindow("Please fill the event start and end dates before event details");
$(currentVal).val('');
return false;
}
if(lastDate < currentDate){
alertWindow("Plesae ensure that last date of entry is greater than current date.");
$(currentVal).val('');
return false;
}else if(lastDate > eveStartDt){
alertWindow("Please ensure that last date of entry is lesser than event start date.");
$(currentVal).val('');
return false;	 	    	 
}
return true;
}

function str2obj(str)
{
var date=str.substring(0,2);
var month=str.substring(3,6);    
var mon = str2mon(month);
var year=str.substring(7,12);

datestr1=year+'-'+mon+'-'+date;
var dateobj1 = new Date(datestr1);
return dateobj1;
}

function str2mon(month)
{
if(month == 'Jan'){
mon = '01';
return mon;	
}

else if(month == 'Feb'){
mon = '02';
return mon;
}

else if(month == 'Mar'){
mon = '03';
return mon;
}

else if(month == 'Apr'){
mon = '04';
return mon;
}

else if(month == 'May'){
mon = '05';
return mon;
}

else if(month == 'Jun'){
mon = '06';
return mon;
}

else if(month == 'Jul'){
mon = '07';
return mon;
}

else if(month == 'Aug'){
mon = '08';
return mon;
}

else if(month == 'Sep'){
mon = '09';
return mon;
}

else if(month == 'Oct'){
mon = '10';
return mon;
}
else if(month == 'Nov'){
mon = '11';
return mon;
}
else if(month == 'Dec'){
mon = '12';
return mon;
}
}

function showDiv(){
$('#requestDiv').show();
}
function hideDiv(){
$('#requestDiv').hide();
}
function hideSlider(counter){
var speed = 300;

//$('#entries'+counter).val('');
//$('#backupNum'+counter).val('');
//$('#startDateStrEvent'+counter).val('');
//$('#endDateStrEvent'+counter).val('');
//$('#entriesLastDate'+counter).val('');
//$('#entryFees'+counter).val('');
//$('#entriesFeesLastDate'+counter).val('');
//$('#playsOff'+counter).val('Yes');
//$('#prizeMoney'+counter).val('');

$('#sliderContainer').slideUp(speed);
//$('#sliderContainer').hide();
$('.eventDetailstable').hide();
}

function cityRequest(){
$('#cityMsg').html("");
thickbox('New City Request', '#TB_inline?height=250&width=320&inlineId=cityRequest');
}

function sendCityRequest(){	
var cityText = $('#cityText').val();
if(cityText == '' || cityText == 'Please enter City,State and Country.'){
$('#cityMsg').html("Please enter city name.");
return false;
}
$.post('/ajax/tms/sendCityRequest.htm?cityText='+cityText, function(data) {
$('#cityMsg').html("Request Successfully Submitted");

setTimeout(function() {
$(".specialrequest").hide();
}, 3000);			 
}); 
}
function moreDetails(){
$("#addMoreDetails").show();;
}
function createClub(){
thickbox('Create a Club', '#TB_inline?height=350&width=550&inlineId=createClubForm');
}
function slideEventDetails(id){
var url = "#selectBox";
window.location.href = url;
var selected = $('#'+id).find(':selected').val();
var isVisible = $('#sliderContainer').is(':visible');
if (isVisible){	 
alertWindow("Please fill event details or close the previously opend Event details.");   
}else if(selected != '0'){
$("#eventDetails_"+selected.split("|")[1]).show();
$("#sliderContainer").slideToggle();
}
}
function checkSearchtournamentEdit(editEventMasterId)
{
if(editEventMasterId != ''){
$("#eventDetails_"+editEventMasterId).show();
$("#sliderContainer").slideToggle();
}
}
function showHideEntryFee(pmode)
{
var tournamentId = $('#tournamentId').val();
var url = '/tms/ajax/countTotalEvent.htm?tournamentId=' + tournamentId;
$.getJSON(url, function(data) {
allEventsCount = data.allEventsCount;
if(pmode == 'entryFree'){
for(i=1;i<=allEventsCount;i++){
$("#entryFreeLable_"+i).hide();
$("#entryFreeValues_"+i).hide();

$("#eventEntryFeeLable").hide();
$("#eventFeeDateLable").hide();
$("#eventEntryFreeValue_"+i).hide();
$("#eventFeeDateValue_"+i).hide();
}
}
});
}

function showHidePrizeMoney(pmoney)
{
var tournamentId = $('#tournamentId').val();
var url = '/tms/ajax/countTotalEvent.htm?tournamentId=' + tournamentId;
$.getJSON(url, function(data) {
allEventsCount = data.allEventsCount;
if(pmoney == '0' || pmoney == '2'){
for(i=1;i<=allEventsCount;i++){
$('#eventDetailPrizeMoneyLable_'+i).hide();
$('#eventDetailPrizeMoney_'+i).hide();
$('#eventPrizeMoneyLable').hide();
$('#eventPrizeAmountValue_'+i).hide();
}
}
});
}

function editEventDetails(eventId,eventmasterId){
var speed = 100;
var counter = eventmasterId-1;
var isVisible = $('#sliderContainer').is(':visible');
//if (isVisible){	 
$('.eventDetailstable').hide();
$('#sliderContainer').slideUp(speed);
$('#sliderContainer').slideDown(speed);
$("#eventDetails_"+eventmasterId).show();
$('#eventId'+counter).val(eventId);
//}else{
//	$('.eventDetailstable').hide();
//$('#sliderContainer').slideDown(speed);
//$("#eventDetails_"+eventmasterId).show();
// }
}

function saveEventDetails(counter){
/* 		if(etStartDt == "" || etEndDt == ""){			 
alertWindow("Please fill the event start and end dates before event details");
$(currentVal).val('');
return false;
} */

var pageN = 1;
var paymentMode = $('#pmode').val();
var prizeMoneySel = $('#pmoney').val();
var tournamentId = $('#tournamentId').val();
var eventMasterId = $('#eventMasterId'+counter).val();
var eventId = $('#eventId'+counter).val();
var eventName = $('#eventName'+counter).val();
var entries = $('#entries'+counter).val();
var backupNum = $('#backupNum'+counter).val();
var entryFees = $('#entryFees'+counter).val();		
var playsOff = $('#playsOff'+counter).val();
var startDateStrEvent = $('#startDateStrEvent'+counter).val();
var endDateStrEvent = $('#endDateStrEvent'+counter).val();
var entriesLastDate = $('#entriesLastDate'+counter).val();
var entriesFeesLastDate = $('#entriesFeesLastDate'+counter).val();
var prizeMoney = $('#prizeMoney'+counter).val();

if(entries == "0" || startDateStrEvent == "" || endDateStrEvent == "" || entriesLastDate == ""){			
alertWindow("Please fill the mandatory field before save the details.");
return false;
}
if(paymentMode != 'entryFree'){
if(entryFees == "" || entriesFeesLastDate == ""){			
alertWindow("Please fill the mandatory field before save the details.");
return false;
}
}
if(entryFees != '')
{
if(isNaN(entryFees) || !entryFees.match(/^\d+/)){
alertWindow("Please enter valid numeric characters for Entry Fees!")
return false;
}
}
if(prizeMoney != ""){
if(isNaN(prizeMoney) || !prizeMoney.match(/^\d+/))
{
alertWindow("Please enter only numeric characters for Prize Money!")
return false;
}
}
if(prizeMoneySel == '1'){
if(prizeMoney == ""){
alertWindow("Please fill the mandatory field before save the details.");
return false;
}
}



hideSlider();
var url = '/tms/ajax/saveEventDetailsForm.htm?pageN=' + pageN + '&tournamentId=' + tournamentId +'&eventMasterId='+ eventMasterId + '&eventId=' +eventId + '&eventName=' + eventName + '&entries=' + entries
+ '&backupNum=' + backupNum +'&entryFees='+entryFees+ '&playsOff='+playsOff +'&startDateStrEvent=' + startDateStrEvent + '&participateFlag=yes'
+ '&endDateStrEvent=' + endDateStrEvent + '&entriesLastDate=' +entriesLastDate + '&entriesFeesLastDate=' +entriesFeesLastDate +'&prizeMoney=' +prizeMoney+'&eventCounter='+counter+'&view=ajax';
//var url = '/tms/saveEventDetailsForm.htm?&participateFlag=yes&eventCounter='+counter;
$.get(url, function(data) {
$('#eventListContainer').html(data);
var eventurl = '/tms/ajax/countTotalEvent.htm?tournamentId=' + tournamentId;
$.getJSON(eventurl, function(row) {
var allEventsCount = row.allEventsCount;
for (i=1;i<=allEventsCount;i++){
if(paymentMode == 'entryFree'){
$("#eventEntryFeeLable").hide();
$("#eventFeeDateLable").hide();
$("#eventEntryFreeValue_"+i).hide();
$("#eventFeeDateValue_"+i).hide();
}
if(prizeMoneySel == '0' || prizeMoneySel == '2'){
$('#eventPrizeMoneyLable').hide();
$('#eventPrizeAmountValue_'+i).hide();
}
}
});
});
return;
}

function deleteEventDetail(eventId,eventMasterId,tournamentId){
hideSlider();	
var url = '/tms/ajax/deleteEventDetail.htm?eventId=' + eventId + '&tournamentId=' + tournamentId  + '&eventMasterId=' + eventMasterId +'&view=ajax' + '&participateFlag=yes';

$.get(url, function(data) {
$('#eventListContainer').html(data);
});
return;	

}

function validateEventDates(eventDateStr,currentVal,flag)
{	
var SDate = $("#startDateStr").val();
var EDate = $("#endDateStr").val();

var tStartDate = str2obj(SDate);
var tEndDate = str2obj(EDate);
var eventDate = str2obj(eventDateStr);


if(!validateTornamentDates(currentVal)){

return false;
}
if(flag == "eventStartDate"){
if(tStartDate > eventDate)
{
alertWindow("Please ensure that event start date is within the range of tournament dates.");
//$(currentVal).val(SDate);
$(currentVal).val("");
return false;
}
else if(eventDate > tEndDate){
alertWindow("Please ensure that event start date is within the range of tournament dates.");
//$(currentVal).val(SDate);
$(currentVal).val("");
return false;
}
}else{
if(eventDate < tStartDate)
{
alertWindow("Please ensure that event end date is within the range of tournament dates.");
//$(currentVal).val(EDate);
$(currentVal).val("");
return false;
}
else if(eventDate > tEndDate){
alertWindow("Please ensure that event end date is within the range of tournament dates.");
//$(currentVal).val(EDate);
$(currentVal).val("");
return false;
}

}
return true;
}

function getGeoIpLocation(city){
var cityId = city.val();
if(cityId == ''){
//alertWindow("Please enter City.");
//return false;
} 
var url = '/ajax/cityNameLatitudeLongitudeList.htm?cityId=' + cityId;
$.get(url, function(data) {
var content = data.split('|');
if(typeof(content[0]) == "undefined"){
$('#geoCityName').val('');
}else{
$('#geoCityName').val(content[0]);
}

if(typeof(content[2]) == "undefined"){
$('#latitude').val('aa');
}else{
$('#latitude').val(content[2]);
}

if(typeof(content[3]) == "undefined"){
$('#longitude').val('bb');
}else{
$('#longitude').val(content[3]);
}
addMarker(content[2],content[3]);
});
thickbox('Create a Club', '#TB_inline?height=350&width=550&inlineId=GeoLocation');
}



</script>

<div id="ciHomeContent1240"><script type="text/javascript">
if(screen.width <= 1200 || '${showAdd}' == 'false') {
$('#ciHomeContent1240').attr('id', 'ciHomeContent980');
}
</script>
<script type="text/javascript">
$(function() {
$('#startDateStr').datepicker({ 
yearRange: "-60:+10",
showOn: "button",
buttonImage: "/images/calendar.gif",
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
dateFormat: 'dd-M-yy', 
onSelect:
function(dateText, inst) {
validateTornamentSEDates('#startDateStr');
$('#startDateStr').text(dateText);
//showHideReset($('#startDateStr'));
}
});
$('#endDateStr').datepicker({ 
yearRange: "-60:+10",
showOn: "button",
buttonImage: "/images/calendar.gif",
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
dateFormat: 'dd-M-yy', onSelect:
function(dateText, inst) {
validateTornamentSEDates('#endDateStr');
$('#endDateStr').text(dateText);
//showHideReset($('#endDateStr'));
}
});

$("body").click(function(event) {
var $target = $(event.target);
if (!$target.is(".ui-datepicker") && $target.parents(".ui-datepicker").size() == 0) {
$(".hasDatepicker").datepicker("hide"); 
}
});
});



function showHide(showId, hideId, showTxt){
$(hideId).hide();
$(showId).show();
if(showTxt == 'show'){
$('.showMore').show();
}

if(showTxt == 'hide'){
$('.showMore').hide();
}
}


</script> 
<script>
$(document).ready(function(){
//Collapse div
//$('.moreDetails').collapsible();
// Remove css class if IE7 browser will be detected....			
if((document.all)&&(navigator.appVersion.indexOf("MSIE 7.")!=-1 || navigator.appVersion.indexOf("MSIE 10.")!=-1 )){
$('div').removeClass('select');
$("#menSelectBox").addClass('select200');
$("#womenSelectBox").addClass('select200');
$("#mixedSelectBox").addClass('select200');
$("#boysSelectBox1").addClass('select200');
$("#boysSelectBox2").addClass('select200');
$("#girlsSelectBox1").addClass('select200');
$("#girlsSelectBox2").addClass('select200');
$("#bgmixedSelectBox").addClass('select200');
$("#noviceSelectBox").addClass('select200');				
}else{
//Fancy select box
$("#menSelectBox").selectbox();
$("#womenSelectBox").selectbox();
$("#mixedSelectBox").selectbox();
$("#boysSelectBox1").selectbox();
$("#boysSelectBox2").selectbox();
$("#girlsSelectBox1").selectbox();
$("#girlsSelectBox2").selectbox();
$("#bgmixedSelectBox").selectbox();
$("#noviceSelectBox").selectbox();
}	

$(".specialrequest").hide();
$(".show_hide").show();
if($("#pmode").val() != 'Online'){
$('#paymentInstLable').hide();
$('#paymentInst').hide();
}
$('.show_hide').click(function(){
$(".specialrequest").slideToggle();
});
// ********************   Code Block for sliding Div on Event Selection    *****************
$("#sliderContainer").hide(); 
//$('#menSelectBox').change(function(){
//var selected = $('#menSelectBox').find(':selected').val();
//var isVisible = $('#sliderContainer').is(':visible');
//if (isVisible){	 
//alertWindow("Please fill event details or delete the previously opend Event details.");   
//}else{
//$("#eventDetails_"+selected.split("|")[1]).show();
//$("#sliderContainer").slideToggle();
// }
//}); 
// ********************   Code Block for sliding Div on Event Selection    *****************
jQuery("#tmsTournamentView").validate({
errorLabelContainer: "#containererreurtotal",
wrapper: "p",
errorClass: "error",

rules: {
startDateStr:"required",
endDateStr:"required",
currencyId:{ valueNotEquals: "currency" }, 
paymentMode:{ valueNotEquals: "payMode" },
prizeMoney:{ valueNotEquals: "prize" },
email:{
required: true,
email: true
}	  			
},
messages: {
startDateStr:"Please enter the start date",
endDateStr:"Please enter the end date",
currencyId:{ valueNotEquals: "Please select currency !" },
paymentMode:{ valueNotEquals: "Please select Payment mode !" },
prizeMoney:{ valueNotEquals: "Please select Prize money !" },
email: {
required: "We need your email address to contact you",
email: "Your email address must be in the format of name@domain.com"
}
},
invalidHandler: function(form, validator) {
$("#containererreurtotal").show();
},
unhighlight: function(element, errorClass) {
if (this.numberOfInvalids() == 0) {
$("#containererreurtotal").hide();
}
$(element).removeClass(errorClass);
} 

});
checkSearchtournamentEdit($("#searchtournamentEditEventMasterId").val());
showHideEntryFee($("#pmode").val());
showHidePrizeMoney($("#pmoney").val());
});
// $.validator.messages.required = "please select the currency.!";

function validateTornamentSEDates(currentDate)
{ 
var SDate = $("#startDateStr").val();
var EDate = $("#endDateStr").val();

var startDate=str2obj(SDate);
var endDate=str2obj(EDate);
var now = new Date();

now.setDate(now.getDate() - 1);
if(SDate == ""){
alertWindow("Please fill tournament's start date.");
$(currentDate).val('');
return false;
}	 
if(SDate == "" && EDate == ""){
alertWindow("Please fill tournament start and end dates before event details");
$(currentDate).val('');
return false;
}
if(startDate < now){
alertWindow("Please ensure that tournament start date should not be past date.");
$("#startDateStr").val("");
return false;
}
if(startDate > endDate)
{
alertWindow("Please ensure that tournament end date is greater than or equal to start date.");
$("#endDateStr").val("");
return false;
}
return true;
}
</script>
<%! Long courtType = 0L; %>
<div style="height: auto; width: 910px; min-height: 485px">
<div id="outerWrapperTms">
<div id="headerTms">



<%--  <c:if test="${not empty param.tournamentId}">
<div id="subheaderTms">
<jsp:include page="tmsSubHeaderText.jsp">	
<jsp:param name="createTournament" value="${createTournament}" />
<jsp:param name="editTournament" value="${editTournament}" />
</jsp:include>

<div style="float:right;" class="subheaderRight"> 
<strong>
<a style="text-decoration:underline" href="">Back to Tournament Creation</a>
</strong>
<jsp:include page="tournamentMenu.jsp"/>
</div>
</div>
</c:if> --%>
<!-- ************************* tournamentDetails Div Start ******************************************** -->
<div id="contentWrapperTms">
<input type="hidden" id="searchtournamentEditEventMasterId" name="searchtournamentEditEventMasterId" value="${searchtournamentEditEventMasterId}" />

<div class="tournament_main">
<fmt:formatDate value="${tournament.startDate}" pattern="dd-MMM-yyyy"  var="startDate"/>
<fmt:formatDate value="${tournament.endDate}" pattern="dd-MMM-yyyy"  var="endDate"/>
<form name="tmsTournamentView" id="tmsTournamentView" method="post" action="${conf.TE_HOME}/tms/tournamentEvent.htm?eve=yes" onsubmit="return validateCalendar();">
<input type="hidden" id="tournamentId" name="tournamentId" value="${tournamentId}" />
<input type="hidden" id="tournamentCreationMsg" name="tournamentCreationMsg" value="${tournamentCreationMsg}" />
<input type="hidden" id="creationEntityType" name="creationEntityType" value="Create Tournament" />
<input type="hidden" id="loginEntityName" name="loginEntityName" value="${sessionScope.loginEntityName}" />
<table width="100%" border="0" class="createtable" style="margin:20px 0">
<tr>
<c:set var ="inputCreateVal" value="Enter Tournament Name" />
<td style="text-align:center" class="oddBig">
<input type="text" 
value="${inputCreateVal}" onfocus="if($(this).val() == '${inputCreateVal}'){$(this).val('')}"
onblur="if($(this).val() == ''){$(this).val('${inputCreateVal}')}" 
name="tournamentName" id="tournamentName" size="10" class="input600" value="${tournament.tournamentName}" style="width:500px;height:21px" /><span style="color:red">*</span>
<c:if test="${not empty sessionScope.user || sessionScope.user != null}">
<c:if test="${empty tournamentId}">
<input type="button" id="createTournamentImg" value="Create Tournament" style="cursor:pointer;" class="buttonBtn blueBtn" onclick="createTournament();" />
</c:if>
</c:if>
<br />
<div id="createMessage" class="textred"></div>
</td>
</tr>
<c:if test="${empty sessionScope.user || sessionScope.user == null}">
<tr>
<td style="text-align:center" class="oddBig">
	
</td>
</tr>
<tr>
<td style="text-align:center" class="oddBig">
<c:if test="${empty tournamentId}">
<input type="button" id="createTournamentImg" value="Create Tournament" style="cursor:pointer;" class="buttonBtn blueBtn" onclick="login_registerUser('createTournament');" />
</c:if>
</td>
</tr>
</c:if>
</table>
<!-- *****************  tournament details div start   **************  -->
<div id="tournamentDetails" class="tms-mainwrap" <c:if test="${tournament.tournamentId == null}"> style="display: none;" </c:if>>
<div id="subheaderTms"><img src="${cdnPath}/images/courtmgm/download-icosmall.png" border="0" style="float:left" alt="Time Shift" />
<h2>Tournament Details</h2>		

<div class="subheaderRight">        
</div>
</div>
<div style="width:820px;margin:0 25px 0 30px;float:left">
<table width="800px" border="0" cellspacing="2" cellpadding="2" class="createtable">
<tr>
<td colspan="2" class="playtable_text">Tournament Dates<span style="color: #FF0000">*</span></td>
<td style="width:200px"><img src="/images/spacer.gif" style="width:185px;height:10px"/></td>
<td class="playtable_text" colspan="2">Currency<span style="color: #FF0000">*</span></td>
</tr>
<tr>
<td colspan="2"><span class="smalltxt">Start Date</span>
<input size="12" readonly="readonly" id="startDateStr" type="text" name="startDateStr" value="${startDate}" class="input60" />
&nbsp;&nbsp;<span class="smalltxt">End Date</span>
<input size="12" readonly="readonly" id="endDateStr" type="text" name="endDateStr" value="${endDate}"  class="input60" /></td>
<td style="width:200px"><img src="/images/spacer.gif" style="width:185px;height:10px"/></td>
<td colspan="2">
<select name="currencyId" class="select150" id="currencyId" style="width: 300px">
<option value="currency" selected="selected">Select Currency</option>
<c:forEach items="${currencies}" var="currency">
<option value="${currency.id}" <c:if test="${tournament.currencyId == currency.id}"> selected="selected" </c:if>>${currency.code} (${currency.symbol})</option>
</c:forEach>
</select></td>
</tr>

<tr>
<td colspan="2" class="playtable_text">Co-ordinator's Email<span style="color: #FF0000">*</span></td>
<td>&nbsp;</td>
<td class="playtable_text" colspan="2">URL<span style="color: #FF0000">*</span></span></td>
</tr>
<tr>

<c:choose>
<c:when test="${empty tournament.email}">
<c:set value="${sessionScope.user.email}" var="cordinatorEmail"></c:set>				      
</c:when>
<c:otherwise>
<c:set value="${tournament.email}" var="cordinatorEmail"></c:set>
</c:otherwise>
</c:choose>

<td colspan="2"><input name="email" id="email" value="${cordinatorEmail}" class="input150" type="text" style="width:290px" /></td>
<td>&nbsp;</td>
<td colspan="2"><span class="smalltxt">tennisearth.com/tms/tournament/&nbsp;</span>
<c:choose>
<c:when test="${empty tournament.tournamentName}">
<c:set value="${tournamentName}" var="urlName"></c:set>				      
</c:when>
<c:otherwise>
<c:set value="${tournament.tournamentName}" var="urlName"></c:set>
</c:otherwise>
</c:choose>
<input id="url" name="url" value="${tournament.url}" maxlength="25" class="input60" type="text" style="width:125px" onkeyup="checkURLDuplicacy(this.value);"/><br />
<div id="urlNameError" class="textredlogin" style="height: 8px;"></div>
<div id="urlNameAvailable" class="textgreen" style="padding-left: 162px;height: 8px"></div>
</td>
</tr>
<tr>
<td colspan="2" class="playtable_text">Payment Mode<span style="color: #FF0000">*</span></td>
<td>&nbsp;</td>
<td class="playtable_text" colspan="2">Prize Money<span style="color: #FF0000">*</span></td>
</tr>
<tr>
<td colspan="2">
<select name="paymentMode" id="pmode" class="select150" style="width: 300px" onchange="updateOnchangePaymentModeAlert(this);">
<option value="payMode" selected="selected">Select Payment Mode</option>
<option value="entryFree" <c:if test="${tournament.paymentMode == 'entryFree' }">selected="selected""</c:if>>Entry Free</option>
<option value="Offline" <c:if test="${tournament.paymentMode == 'Offline' }">selected="selected""</c:if>>Offline</option>
<option value="Online" <c:if test="${tournament.paymentMode == 'Online' }">selected="selected""</c:if>>Online</option>
</select>
<c:set var="paymentModeVal" value="${tournament.paymentMode}" />                     </td>
<td>&nbsp;</td>
<td colspan="2"> 
<select name="prizeMoney" id="pmoney" class="select150" style="width: 300px" onchange="updateOnchangeEventPrizeMoneyAlert(this);">

<option value="prize" selected="selected">Select Prize money</option>
<option value="0" <c:if test="${tournament.prizeAmount == 0 }">selected="selected""</c:if>>No</option>
<option value="1" <c:if test="${tournament.prizeAmount == 1 }">selected="selected""</c:if>>Yes</option>
<option value="2" <c:if test="${tournament.prizeAmount == 2 }">selected="selected""</c:if>>Declare later</option>
</select>
<c:set var="prizeMoneyVal" value="${tournament.prizeAmount}" />					 </td>
</tr>
<tr id="paymentInstLable">
<td class="playtable_text" colspan="5">Payment Instruction</td>
<%--<td>&nbsp;</td>
<td class="playtable_text" colspan="2">&nbsp;</td>--%>
</tr>
<tr id="paymentInst">
<td colspan="5"><textarea name="paymentInstructions" cols="20" rows="8" value="${tournament.paymentInstructions}" maxlength="256" class="input600" type="text" style="height:30px;width:785px"></textarea></td>
</tr>

<tr>
<td colspan="5" style="width:800px;padding:15px 0 10px 0"><center><span style="color:#000099"><strong>Add more details on your tournament web page</strong></span>&nbsp;&nbsp;<span id="plsImg"><img src="/images/plus-icon.png" onclick="showHide('#minImg', '#plsImg','show')" style="cursor:pointer" /></span><span id="minImg" style="display:none;"><img src="/images/minus-ico.png" onclick="showHide('#plsImg', '#minImg','hide')" style="cursor:pointer" /></span></center>					</td></tr>
<tr class="showMore" style="display:none">
<td colspan="5" class="playtable_text">Tournament Details</td>
</tr>
<tr class="showMore" style="display:none">
<td colspan="5" class="playtable_text"><textarea name="description" value="${tournament.description}"
class="input600" type="text" style="height:30px;width:785px" /></textarea></td>
</tr>
<tr class="showMore" style="display:none">
<td class="playtable_text" style="width230px">Select the Club</td>
<td align="right" style="text-align:right;padding-right:10px;vertical-align:bottom;width:110px"><a id="createClub" onclick="createClub();" class="thickbox tooltip" style="color:#0033FF;cursor:pointer;font-weight:normal;text-decoration:underline">Create a Club</a></td>
<td style="width:110px">&nbsp;</td>
<td colspan="2"><span class="playtable_text">Co-ordinator's Name</span></td>
</tr>

<tr class="showMore" style="display:none">
<td colspan="2" class="playtable_text">

<input type="hidden" id="club1b" name="clubId" value="${tournament.club.clubId}"/> 
<input type="text" id="club" name="clubName" class="input150" style="width:290px"
value="${tournament.club.name}" onfocus="if(this.value=='Search here') this.value='';"
onblur="if(this.value=='') {this.value='Search here';$('#club1b').val('');}" />
<br>
<script type="text/javascript"><!--
var club1b = $('#club');
club1b.autocomplete('/ajax/tms/getClubNames.htm', {  minChars:2, max:100, cacheLength:100, matchContains:true, autoFill:false, selectFirst:true });		
club1b.result(function(event, data, formatted) {
$('#club1b').val(data[1]);
});
// --> </script>                              </td>
<td>&nbsp;</td>
<c:choose>
<c:when test="${empty tournament.cordinatorName}">
<c:choose>
<c:when test="${empty sessionScope.user.firstName || sessionScope.user.lastName}">
<c:set value="${sessionScope.user.screenName}" var="tCordinatorName"></c:set>
</c:when>
<c:otherwise>
<c:set value="${sessionScope.user.firstName} ${sessionScope.user.lastName}" var="tCordinatorName"></c:set>
</c:otherwise>
</c:choose>				      
</c:when>
<c:otherwise>
<c:set value="${tournament.cordinatorName}" var="tCordinatorName"></c:set>
</c:otherwise>
</c:choose>
<td colspan="2" class="playtable_text"><input name="cordinatorName" value="${tCordinatorName}" class="input150" type="text" style="width:290px" /></td>
</tr>
<tr class="showMore" style="display:none">
<td colspan="2" class="playtable_text">Court Type</td>
<td>&nbsp;</td>
<td colspan="2" class="playtable_text">Contact number</td>
</tr>

<tr class="showMore" style="display:none">

<%

%>
<td colspan="2"><select name="courtType" class="select150" style="width: 300px">
<option value="101">Select Surface</option>
<option value="1" <%if(courtType == 1){ %>selected="selected" <%} %>>Grass</option>
<option value="2" <%if(courtType == 2){ %>selected="selected" <%} %>>Hard</option>
<option value="3" <%if(courtType == 3){ %>selected="selected" <%} %>>Clay</option>
<option value="5" <%if(courtType == 5){ %>selected="selected" <%} %>>Astro Turf</option>
<option value="4" <%if(courtType == 4){ %>selected="selected" <%} %>>Others</option>
</select>								  </td>
<td>&nbsp;</td>

<td colspan="2"><input type="text" id="contact" name="contact" value="${tournament.contact}" class="input150" style="width:290px" /></td>
</tr>
<tr class="showMore" style="display:none">
<td class="playtable_text">City</td>
<td style="text-align:right;padding-right:10px;vertical-align:bottom"><a href="javascript:void(0)" class="show_hide" style="color:#0033FF;cursor:pointer;font-weight:normal;text-decoration:underline">Request for new city</a></td>
<td>&nbsp;</td>
<td colspan="2" class="playtable_text">Time Zone</td>
</tr>
<tr class="showMore" style="display:none">
<td colspan="2" class="playtable_text">

<input type="hidden" id="city" name="cityId" value="${tournament.cityId}" class="input150" style="width:290" />
<c:set var="cityName" value="${tournament.cityObj.cityName}"></c:set>
<c:if test="${not empty tournament.cityObj.state}">
<c:set var="cityName" value="${cityName}(${tournament.cityObj.state.stateName}"></c:set>
</c:if>
<c:if test="${not empty tournament.cityObj.state.country}">
<c:set var="cityName" value="${cityName}, ${tournament.cityObj.state.country.countryName})"></c:set>
</c:if>
<c:if test="${empty cityName}">
<c:set var="cityName" value="Search here"></c:set>
</c:if>
<input type="text" id="cityName" name="cityName" size="10" class="input150" style="width:290px" value="${cityName}" onfocus="if(this.value=='Search here') this.value='';"
onblur="if(this.value=='') {this.value='Search here';$('#city').val('');}" />
<br />

<div class="specialrequest" style="padding-left:0">						
<input type="text" title="Enter your comments" id="cityText" name="specialReq" class="input150" style="width:240px"  onfocus="if(this.value=='Please enter City,State and Country.') this.value='';" onblur="if(this.value=='') this.value='Please enter City,State and Country.';" autocomplete="off" />
<img src="/images/courtmgm/enterold.png" onclick="sendCityRequest()" style="cursor:pointer; vertical-align:top" />&nbsp;&nbsp;<a class="show_hide tooltip" title="remove" style="cursor:pointer;text-decoration:none"><!--<img src="/images/deletebtn.gif" style="cursor:pointer; vertical-align:top" class="delete tooltip" title="remove" />--><span style="color:red;font-size:14px;font-weight:bold">X</span></a>
<br /><div id="cityMsg"></div>
</div>										 </td>
<script type="text/javascript">
var cityName = $('#cityName');
cityName.autocomplete('/ajax/cityNameList.htm', { minChars:2, max:100, cacheLength:100, matchContains:true, autoFill:false, selectFirst:false });		
cityName.result(function(event, data, formatted) {
$('#cityName').val(data[0]);
$('#city').val(data[1]);
$('#geoIpCityId').val(data[1]);	
});
</script></td>
<td>&nbsp;</td>
<td colspan="2">

<select name="timeZoneId" id="timeZoneId" class="select150" style="width:300px">
<option value="">Select</option>
<c:forEach var="tz" items="${timeZones}">
<option value="${tz.id}" <c:if test="${tournament.timeZoneId == tz.id}"> selected="selected" </c:if>>(UTC${tz.timeZoneOffset}) ${tz.timeZoneId}</option>
</c:forEach>
</select></td>
</tr>
<tr class="showMore" style="display:none">
<td colspan="2" class="playtable_text">Tournament Address</td>
<td>&nbsp;</td>

<td class="playtable_text">Zip Code</td>
<td style="text-align:right;padding-right:10px;vertical-align:bottom"><a href="javascript:void(0)" onclick="getGeoIpLocation($('#city'));" title="This will make your tournament searchable on search engines" class="tooltip" style="color:#0033FF;cursor:pointer;font-weight:normal;text-decoration:underline">Add Geo Location </a></td>
</tr>
<tr class="showMore" style="display:none">
<td colspan="2" align="left" valign="middle"><input name="address" value="${tournament.address}" class="input150" type="text" style="width:290px" /></td>
<td>&nbsp;</td>
<td colspan="2"><input name="zipCode" id="zipCode" value="${tournament.zipCode}" class="input150" style="width:290px" type="text" />				          </tr>
</table>
</div>
</div>

</form>	 				
</div>	 
<!-- ************************* tournamentDetails Div Start ******************************************** -->

<div class="tournament_main" <c:if test="${empty tournament.tournamentId}"> style="width:99%;display: none;margin-top:10px" </c:if>>
<div id="subheaderTms"><img src="${cdnPath}/images/courtmgm/download-icosmall.png" border="0" style="float:left" alt="Time Shift" />
<h2>Select Events</h2>		  				        
<div class="subheaderRight">        
</div>
</div>
<a name="selectBox"></a>
<div style="margin:0 25px 0 30px;width:820px;float:left">
<table width="100%" border="0" class="" cellpadding="5" cellspacing="2">
<tr>
<td class="tdborder-lt-bt grebg" colspan="3" style="font-size:14px"><div align="left"><strong>ADULTS</strong></div></td>
</tr>
<tr>
<td valign="top" align="left">
<div class="select">
<select name="men" id="menSelectBox" onchange="slideEventDetails(this.id);">
<option value="0" style="font-weight:bold"><strong>Men</strong></option>
<c:forEach var="menEvent" items="${menEventsList}">
<option value="${menEvent.eventName}|${menEvent.eventMasterId}">${menEvent.eventName}</option>
</c:forEach>
</select>
</div>
</td>
<td valign="top" align="center">
<div class="select">
<select name="women" id="womenSelectBox" onchange="slideEventDetails(this.id);">
<option value="0" style="font-weight:bold"><strong>Women</strong></option>
<c:forEach var="womenEventsList" items="${womenEventsList}">
<option value="${womenEventsList.eventName}|${womenEventsList.eventMasterId}">${womenEventsList.eventName}</option>
</c:forEach>
</select>
</div>
</td>
<td valign="top" align="right">
<div class="select">
<select name="mixed" id="mixedSelectBox" onchange="slideEventDetails(this.id);">
<option value="0" style="font-weight:bold"><strong>Mixed</strong></option>
<c:forEach var="mixEventsList" items="${mixEventsList}">
<option value="${mixEventsList.eventName}|${mixEventsList.eventMasterId}">${mixEventsList.eventName}</option>
</c:forEach>
</select>
</div>
</td>
</tr>
<tr>
<td colspan="3" valign="top" align="left">
<div class="select">
<select name="novice" id="noviceSelectBox" onchange="slideEventDetails(this.id);">
<option value="0" style="font-weight:bold"><strong>Novice</strong></option>
<c:forEach var="noviceEvents" items="${noviceEventsList}">
<option value="${noviceEvents.eventName}|${noviceEvents.eventMasterId}">${noviceEvents.eventName}</option>
</c:forEach>
</select>
</div>
</td>
</tr>
<tr><td colspan="3" style="padding:2px">&nbsp;</td></tr>
<tr>
<td colspan="3" class="grebg tdborder-lt-bt" style="font-size:14px"><strong>JUNIORS</strong></td>
<td>                    
</tr>
<tr>
<td class="tdborder-lt-bt grebg" style="font-size:14px"><center><strong>Boys</strong></center></td>
<td class="tdborder-lt-bt grebg" style="font-size:14px"><center><strong>Girls</strong></center></td>
<td class="tdborder-lt-bt grebg" style="font-size:14px"><center><strong>Boys & Girls Mixed</strong></center></td>
</td>
</tr>
<tr>
<td valign="top" align="left">
<div class="select">
<select name="boysSingles" id="boysSelectBox1" onchange="slideEventDetails(this.id);">
<option value="0">Singles</option>
<c:forEach var="boySingleList" items="${boySingleList}">
<option value="${boySingleList.eventName}|${boySingleList.eventMasterId}">${boySingleList.eventName}</option>
</c:forEach>
</select>
</div><br />
<div class="select">
<select name="boysdoubles" id="boysSelectBox2" onchange="slideEventDetails(this.id);">
<option value="0">Doubles</option>
<c:forEach var="boyDoubleList" items="${boyDoubleList}">
<option value="${boyDoubleList.eventName}|${boyDoubleList.eventMasterId}">${boyDoubleList.eventName}</option>
</c:forEach>
</select>
</div>
</td>
<td valign="top" align="center">
<div class="select">
<select name="girlsSingles" id="girlsSelectBox1" onchange="slideEventDetails(this.id);">
<option value="0">Singles</option>
<c:forEach var="girlSingleList" items="${girlSingleList}">
<option value="${girlSingleList.eventName}|${girlSingleList.eventMasterId}" >${girlSingleList.eventName}</option>
</c:forEach>
</select>
</div><br />
<div class="select">
<select name="girlsdoubles" id="girlsSelectBox2" onchange="slideEventDetails(this.id);">
<option value="0">Doubles</option>
<c:forEach var="girlDoubleList" items="${girlDoubleEventsList}">
<option value="${girlDoubleList.eventName}|${girlDoubleList.eventMasterId}">${girlDoubleList.eventName}</option>
</c:forEach>
</select>
</div>
</td>
<td valign="top" align="right">
<div class="select">
<select name="bgmixed" id="bgmixedSelectBox" onchange="slideEventDetails(this.id);">
<option value="0">Select Event</option>
<c:forEach var="boysGirlsMixList" items="${boysGirlsMixEventsList}">
<option value="${boysGirlsMixList.eventName}|${boysGirlsMixList.eventMasterId}">${boysGirlsMixList.eventName}</option>
</c:forEach>
</select>
</div>
</td>
</tr>
</table>
</div></div>


<!-- ************************* tournamentDetails Div End ******************************************** -->	  

<div id="containererreurtotal" style="text-align:center;color: #FF0000"></div>

<div id="eventDetailsError" style="text-align:center;color: #FF0000"></div>
<!-- Create Event list div-->

<div style="display:none" class="tms-mainwrap" id="sliderContainer">
<div id="subheaderTms"><img border="0" alt="Time Shift" style="float:left" src="${cdnPath}/images/courtmgm/download-icosmall.png">
<h2>Event Details</h2>		  				        
<div class="subheaderRight">        
</div>
</div>
<c:set var="i" value="0" scope="page" />
<c:forEach var="event" items="${eventList}">
<input type="hidden" name="eventId" value="${event.eventId}" id="eventId${i}">
<input type="hidden" name="editEventId" value="${event.eventId}" id="editEventId">
<input type="hidden" name="eventName" value="${event.eventMaster.eventName}" id="eventName${i}">
<input type="hidden" name="eventMasterId" value="${event.eventMaster.eventMasterId}" id="eventMasterId${i}">
<fmt:formatDate value="${event.startDate}" pattern="dd-MMM-yyyy"  var="eventStartDate"/>
<fmt:formatDate value="${event.endDate}" pattern="dd-MMM-yyyy"  var="eventEndDate"/>
<fmt:formatDate value="${event.entriesAcceptEndDate}" pattern="dd-MMM-yyyy"  var="entriesAcceptEndDate"/>
<fmt:formatDate value="${event.entriesFeesLastDate}" pattern="dd-MMM-yyyy"  var="entriesFeesLastDate"/>
<div style="width:820px;margin:0 25px 0 30px;float:left">
<table width="800px" border="0" cellspacing="2" cellpadding="2" class="createtable eventDetailstable" id="eventDetails_${event.eventMaster.eventMasterId}" style="display:none;">
<tr>
<td class="playtable_text tdborder-lt-bt grebg" colspan="3" style="font-size: 14px;"><center>${event.eventMaster.eventName}</center></td><!--
<div style="position:absolute;left:785px;padding-top:5px"><img src="/images/cross.png" class="tooltip" title="close" onclick="hideSlider();"/></div>
--></tr>
<!-- *****************  Iterator starts for every event Detail  **************  -->
<tr>
<!-- <td width="46%" class="playtable_text">Draw Type<span style="color: #FF0000">*</span></td> 
<td width="5%">&nbsp;</td> -->
<td width="45%" class="playtable_text">No. of Entries<span style="color: #FF0000">*</span></td>
<td style="width:200px"><img src="/images/spacer.gif" style="width:185px;height:10px"/></td>
<td class="playtable_text" width="45%">Backup No.</td>
</tr>
<tr>
<!--  <td>
<select name="drawType${i}" class="select150" id="drawtype" style="width: 300px">
<option value="currency" selected="selected">Single Elimination</option>
<option value="${currency.id}" >Double Elimination</option>
</select>
</td>
<td>&nbsp;</td> -->
<td>
<select name="numberOfEntries${i}" class="select150" id="entries${i}" style="width: 300px">
<option value="0" >Select Entries</option>
<option value="8" <c:if test="${event.numberOfEntries == '8'}"> selected="selected" </c:if>>2 to 8</option>
<option value="16" <c:if test="${event.numberOfEntries == '16'}"> selected="selected" </c:if>>9 to 16</option>
<option value="32" <c:if test="${event.numberOfEntries == '32'}"> selected="selected" </c:if>>17 to 32</option>
<option value="64" <c:if test="${event.numberOfEntries == '64'}"> selected="selected" </c:if>>33 to 64</option>
<option value="128" <c:if test="${event.numberOfEntries == '128'}"> selected="selected" </c:if>>65 to 128</option>
</select>
</td>
<td>&nbsp;</td>
<td>
<select name="backupNumber${i}" class="select150" id="backupNum${i}" style="width: 300px">
<option value="0" >Select Backup No</option>
<c:forEach var="j" begin="1" end="15" step="1" varStatus ="status">
<option value=${j}<c:if test="${event.backupNumber == j}"> selected="selected" </c:if>>${j}</option>
</c:forEach> 
</select>
</td>
</tr>
<tr>
<td class="playtable_text">Event Dates <span style="color: #FF0000">*</span></td>
<td>&nbsp;</td>
<td class="playtable_text">Last Date of Entry<span style="color: #FF0000">*</span></td>


</tr>
<tr>
<td>
<span class="smalltxt">Start Date</span>
<input size="12" readonly="readonly" id="startDateStrEvent${i}" type="text" name="eventStartDate${i}" value="${eventStartDate}" class="input60" />&nbsp;&nbsp;
<span class="smalltxt">End Date</span>
<input size="12" readonly="readonly" id="endDateStrEvent${i}" type="text" name="eventEndDate${i}" value="${eventEndDate}"  class="input60" />
</td>
<td>&nbsp;</td>
<td><span class="smalltxt">Select Date</span>
<input readonly="readonly" size="15" id="entriesLastDate${i}" type="text" name="entriesAcceptEndDate${i}" value="${entriesAcceptEndDate}" class="input60 required fldate" />
</td>

</tr>
<!-- If Tournaments Payment Mode is Entry Free , we will not show following Options  [Tag Starts......] -->
<tr id="entryFreeLable_${event.eventMaster.eventMasterId}">
<td class="playtable_text">Entry Fee<span style="color: #FF0000">*</span></td>
<td>&nbsp;</td>
<td class="playtable_text">Last date of fee submission<span style="color: #FF0000">*</span></td>
</tr>
<tr id="entryFreeValues_${event.eventMaster.eventMasterId}">
<td>
<c:if test="${not empty tournament}">
${tournament.currency.symbol}&nbsp;
</c:if>	
<input name="entryFees${i}" value="${event.entryFees}" id="entryFees${i}" onkeypress="return onlyNumbers(event, '');" class="input150" type="text" style="width:290px" />
</td>
<td>&nbsp;</td>
<td><span class="smalltxt">Select Date</span>
<input readonly="readonly" size="15" id="entriesFeesLastDate${i}" type="text" name="entriesFeesLastDate${i}" value="${entriesFeesLastDate}" class="input60 required fldate" />
</td>
</tr>
<!-- If Tournaments Payment Mode is Entry Free , we will not show following Options  [Tag Ends......] -->	
<tr>
<td class="playtable_text">PlayOff's for 3rd and 4th position</td>
<td>&nbsp;</td>
<!-- If Tournaments Prize Amount is No , we will not show Prize Money Options  [Tag Starts......] -->
<td class="playtable_text" id="eventDetailPrizeMoneyLable_${event.eventMaster.eventMasterId}">Prize Money<span style="color: #FF0000">*</span></td>
<!-- If Tournaments Prize Amount is No , we will not show Prize Money Options  [Tag Ends......] -->
</tr>
<tr>

</tr>
<tr>
<td>
<select name="playOffPosition${i}" class="select150" id="playsOff${i}" style="width: 300px">
<option value="true" <c:if test="${event.playOffPosition == '1'}"> selected="selected" </c:if>>Yes</option>
<option value="false" 	<c:if test="${event.playOffPosition == '0'}"> selected="selected" </c:if>>No</option>
</select>
</td>
<td>&nbsp;</td>
<!-- If Tournaments Prize Amount is No , we will not show Prize Money Options  [Tag Starts......] -->
<td id="eventDetailPrizeMoney_${event.eventMaster.eventMasterId}">
${tournament.currency.symbol}&nbsp;
<input name="prizeMoney${i}" value="${event.prizeAmount}" id="prizeMoney${i}" onkeypress="return onlyNumbers(event, '');" class="input150" type="text" style="width:272px" />
</td>
<!-- If Tournaments Prize Amount is No , we will not show Prize Money Options  [Tag Ends......] -->
<td>&nbsp;</td>
</tr>

<tr>
<td colspan="3" align="center" style="text-align:center;border-top:1px solid #ccc;">
<input class="buttonBtn blueBtn" style="cursor: pointer;color:#fff;text-decoration:none;" type="submit" value="Save" name="submit" onclick="saveEventDetails(${i});">&nbsp;&nbsp; 
<input class="buttonBtn blueBtn" style="cursor: pointer;color:#fff;text-decoration:none;" type="button" title="close" value="Close" name="close" onclick="hideSlider(${i});">   
</td>
</tr>

<script type="text/javascript">
$('#entriesLastDate${i}').datepicker({				
showOn: "button",
buttonImage: "/images/calendar.gif",
buttonImageOnly: true, 
changeMonth: true,
changeYear: true,
dateFormat: 'dd-M-yy',  
onSelect:
function(dateText, inst) {
validateLastDtOfEntry(dateText,'#entriesLastDate${i}','#startDateStrEvent${i}','#endDateStrEvent${i}');
$('#entriesLastDate${i}').text(dateText);
//showHideReset($('#entriesLastDate${i}'));
}
});
$('#startDateStrEvent${i}').datepicker({ 
yearRange: "-60:+10",
showOn: "button",
buttonImage: "/images/calendar.gif",
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
dateFormat: 'dd-M-yy', 
onSelect:
function(dateText, inst) {
$('#startDateStrEvent${i}').text(dateText);
validateEventDates(dateText,'#startDateStrEvent${i}','eventStartDate');
//showHideReset($('#startDateStrEvent${i}'));
}
});

$('#endDateStrEvent${i}').datepicker({ 
yearRange: "-60:+10",
showOn: "button",
buttonImage: "/images/calendar.gif",
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
dateFormat: 'dd-M-yy', onSelect:
function(dateText, inst) {
$('#endDateStrEvent${i}').text(dateText);
validateEventDates(dateText,'#endDateStrEvent${i}','eventEndDate');
//showHideReset($('#endDateStrEvent${i}'));
}
});
$('#entriesFeesLastDate${i}').datepicker({
showOn: "button",
buttonImage: "/images/calendar.gif",
buttonImageOnly: true, 
changeMonth: true,
changeYear: true,
dateFormat: 'dd-M-yy',  
onSelect:
function(dateText, inst) {
$('#entriesFeesLastDate${i}').text(dateText);
validateLastDtOfFees(dateText,'#entriesFeesLastDate${i}','#startDateStrEvent${i}','#endDateStrEvent${i}');							
//showHideReset($('#entriesFeesLastDate${i}'));
}
});

function updateOnchangePaymentModeAlert(current){
var eventCount;
var allEventsCount;
var updateId = current.id;
var selected  = current.options[current.selectedIndex].value;
var tournamentId = $('#tournamentId').val();
var url = '/tms/ajax/countTotalEvent.htm?tournamentId=' + tournamentId;
$.getJSON(url, function(data) {
eventCount = data.eventCount;
allEventsCount = data.allEventsCount;
if(selected == 'entryFree'){
if(eventCount >= 1){
return confirmWindow("If you change payment mode to 'Entry Free', previously saved payment details of events will be deleted.",
function() {
updateOnchangePaymentMode(current,allEventsCount);
},
function() {
$('#'+updateId).val('${paymentModeVal}');
}		
);
}else{
updateOnchangePaymentMode(current,allEventsCount);
}
}else{
updateOnchangePaymentMode(current,allEventsCount);
}
});
}

// Method is used to Update onChange events for (Payment Mode)........
function updateOnchangePaymentMode(current,allEventsCount){
var updateId = current.id;
var tournamentId = $('#tournamentId').val();
var prizeMoneyVal = $('#pmoney').val();
var selected  = current.options[current.selectedIndex].value;
// Condition for Payment Instruction on Online Payment Mode Selection........
if(selected == 'entryFree'){
$('#paymentInstLable').hide();
$('#paymentInst').hide();
}else{
$('#paymentInstLable').show();
$('#paymentInst').show();
}
// Condition for Payment Mode Entry Free........
if(selected == 'entryFree'){
var url = '/tms/ajax/onchangeEventDetailUpdate.htm?updateId=' + updateId + '&tournamentId=' + tournamentId + '&valueSelected=' + selected +'&view=ajax';
$.get(url, function(data) {
$('#eventListContainer').html(data);
for (i=1;i<=allEventsCount;i++){
$("#entryFreeLable_"+i).hide();
$("#entryFreeValues_"+i).hide();

$("#eventEntryFeeLable").hide();
$("#eventFeeDateLable").hide();
$("#eventEntryFreeValue_"+i).hide();
$("#eventFeeDateValue_"+i).hide();

if(prizeMoneyVal == '0' || prizeMoneyVal == '2'){
$('#eventPrizeMoneyLable').hide();
$('#eventPrizeAmountValue_'+i).hide();
}

$('#entryFees'+i).val('');
$('#entriesFeesLastDate'+i).val('');
}
});
}else{
for (j=1;j<=allEventsCount;j++){
$("#entryFreeLable_"+j).show();
$("#entryFreeValues_"+j).show();

$("#eventEntryFeeLable").show();
$("#eventFeeDateLable").show();
$("#eventEntryFreeValue_"+j).show();
$("#eventFeeDateValue_"+j).show();

if(prizeMoneyVal == '0' || prizeMoneyVal == '2'){
$('#eventPrizeMoneyLable').hide();
$('#eventPrizeAmountValue_'+j).hide();
}
}
}
return;
}

function updateOnchangeEventPrizeMoneyAlert(current){
var eventCount;
var allEventsCount;
var updateId = current.id;
var selected  = current.options[current.selectedIndex].value;
var tournamentId = $('#tournamentId').val();
var url = '/tms/ajax/countTotalEvent.htm?tournamentId=' + tournamentId;
$.getJSON(url, function(data) {
eventCount = data.eventCount;
allEventsCount = data.allEventsCount;
if(selected == '0' || selected == '2'){
if(eventCount >= 1){
return confirmWindow("If you change prize money to 'No' or 'Declare later', previously saved prize money will be deleted.",
function() {
updateOnchangeEventPrizeMoney(current,allEventsCount);
},
function() {
$('#'+updateId).val('${prizeMoneyVal}');
}			
);
}else{
updateOnchangeEventPrizeMoney(current,allEventsCount);
}
}else{
updateOnchangeEventPrizeMoney(current,allEventsCount);
}						
});
}

// Method is used to Update onChange events for (Prize Money) ........
function updateOnchangeEventPrizeMoney(current,allEventsCount){
var updateId = current.id;
var tournamentId = $('#tournamentId').val();
var paymentModeVal = $('#pmode').val();
var selected  = current.options[current.selectedIndex].value;
// Condition for Prize Money on 'No' or 'Declare later' Selection........
if(selected == '0' || selected == '2'){
var url = '/tms/ajax/onchangeEventDetailUpdate.htm?updateId=' + updateId + '&tournamentId=' + tournamentId + '&valueSelected=' + selected +'&view=ajax';
$.get(url, function(data) {
$('#eventListContainer').html(data);
for (i=1;i<=allEventsCount;i++){
$('#eventDetailPrizeMoneyLable_'+i).hide();
$('#eventDetailPrizeMoney_'+i).hide();
$('#eventPrizeMoneyLable').hide();
$('#eventPrizeAmountValue_'+i).hide();

if(paymentModeVal == 'entryFree'){
$("#eventEntryFeeLable").hide();
$("#eventFeeDateLable").hide();
$("#eventEntryFreeValue_"+i).hide();
$("#eventFeeDateValue_"+i).hide();
}
$('#prizeMoney'+i).val('');
}
});
}else{
for (i=1;i<=allEventsCount;i++){
$('#eventDetailPrizeMoneyLable_'+i).show();
$('#eventDetailPrizeMoney_'+i).show();
$('#eventPrizeMoneyLable').show();
$('#eventPrizeAmountValue_'+i).show();

if(paymentModeVal == 'entryFree'){
$("#eventEntryFeeLable").hide();
$("#eventFeeDateLable").hide();
$("#eventEntryFreeValue_"+i).hide();
$("#eventFeeDateValue_"+i).hide();
}
}
}
}

</script>
<!-- *****************  Iterator ends for every event Detail  **************  -->
</table></div>
<c:set var="i" value="${i + 1}" scope="page" />
</c:forEach> 
<input type="hidden" name="eventCounter" value="${i}" />
</div> 

<!-- ******************  Event List Include Page starts *******************-->
<div id="eventListContainer" style="margin-top:5px;">

</div>	
<!-- ******************  Event List Include Page starts *******************-->

<!-- CREATE CLUB DIV-->
<div id="createClubForm" style="display:none">
<form name="submitClub" id="submitClub" action="http://www.tennisearth.com/tecoach/save_coach.htm" method="post">
<table width="98%" border="0" cellspacing="0" cellpadding="5" style="margin-left:10px;">
<tr>
<td colspan="2">Note: <span style="color:red">*</span>&nbsp;is mandatory field</td>
<td align="right" style="padding-right:15px;"><a href="${conf.TE_HOME}/clubs/suggest.htm" target="_blank" style="color:#000099"></a></td>
</tr>
<tr>
<td align="center" colspan="3" style="border-top:1px solid #ccc;padding-bottom:10px"></td>
</tr>
<tr style="border-bottom:1px solid #666666;">
<td width="29%" class="form_name" valign="top"><strong>Club Name</strong><span style="color:#FF0000;">*</span></td>
<td width="4%" align="center" valign="top"><strong>:</strong></td>
<td align="left" valign="top">
<input type="text" name="clubName" id="clubName" size="10" class="inputPopClub" value="" onblur="calculateTempShortName(this.value)" /><br />
<div id="clubNameMsg" class="errorTxt"></div>
</td>
</tr>
<tr style="border-bottom:1px solid #666666;">
<td class="form_name" valign="top"><strong>Club Short Name</strong><span style="color:#FF0000;">*</span> </td>
<td align="center" valign="top"><strong>:</strong></td>
<td align="left" valign="top">
<span style="font-size:10px; position:relative;top:-2px">http://tennisearth.com/club/</span> <input type="text" name="clubShortName" id="clubShortName" class="inputPop" style="position:relative;top:0;width:168px" value="" />
<div id="clubShortNameMsg" class="errorTxt"></div>
</td>
</tr>
<tr style="border-bottom:1px solid #666666;">
<td class="form_name" valign="top"><strong>City</strong><span style="color:#FF0000;">*</span></td>
<td align="center" valign="top"><strong>:</strong></td>
<td width="67%" align="left" valign="top">

<input type="hidden" id="clubCityId" name="clubCityId" value="" />
<input type="text" id="clubCityName" name="clubCityName" size="10" class="inputPopClub" value="" onfocus="if(this.value=='Search here') this.value='';"
onblur="if(this.value=='') {this.value='Search here';$('#clubCityId').val('');}" />
<div id="clubCityMsg" class="errorTxt" style="padding-right:40px"></div>
<script type="text/javascript"><!--
var cityName = $('#clubCityName');
cityName.autocomplete('/ajax/cityNameList.htm', {  minChars:2, max:100, cacheLength:100, matchContains:true, autoFill:false, selectFirst:false, parse:function(data){getValData(data, '#clubCityId');} });		
cityName.result(function(event, data, formatted) {
$('#clubCityName').val(data[0]);
$('#clubCityId').val(data[1]);	
});
// --> </script>
</td>
</tr>
<tr style="border-bottom:1px solid #666666;">
<td class="form_name" valign="top"><strong>Club Official Email</strong> <span style="color:#FF0000;">*</span></td>
<td align="center" valign="top"><strong>:</strong></td>
<td align="left" valign="top">
<input type="text" id="clubMail" name="clubMail" size="10" value="" class="inputPopClub" />
<div id="clubMailMsg" class="errorTxt"></div>
</td>
<tr style="border-bottom:1px solid #666666;">
<td class="form_name" valign="top"><strong>Club Contact Number</strong></td>
<td align="center" valign="top"><strong>:</strong></td>
<td align="left" valign="top">
<input type="text" id="clubContactNo" name="clubContactNo" size="10" class="inputPopClub" value="" />
<br />
<span id="1" class="field_font_em" style="word-break:break-all">(Comma separated in +44 123 456 7890 format)</span>	
<div id="clubContactMsg" class="errorTxt"></div>	  
</td>
</tr>
<tr style="border-bottom:1px solid #666666;">
<td class="form_name" valign="top"><strong>Remark</strong></td>
<td align="center" valign="top"><strong>:</strong></td>
<td align="left" valign="top">
<textarea class="textareaPop" style="width:305px"></textarea>		  
</td>
</tr>
<tr>
<td align="center" colspan="3" style="border-bottom:1px solid #ccc;padding-top:10px;"></td>
</tr>
<tr>
<td align="center" colspan="3" style="padding-top:15px"><input type="button" id="submitClub" value="Create club" style="cursor:pointer;" class="buttonBtn blueBtn" onclick="validateClub()"  /></td>
</tr>
</table>
</form>
</div>

<!-- ***********************************      Geo Location Div Starts    ***********************************     -->
<div id="GeoLocation" style="display:none">
<table border="0" cellpadding="0" cellspacing="4" width="970">
<tbody>
<tr valign="top">
<td width="1" style="background-color:#CCCCCC"><img src="${cdnPath}/images/spacer.gif" width="1" height="1" alt="Blank" /></td>	
<td width="*">
<table border="0" width="100%">
<tr>
<td colspan="2"><div id="suggest" class="textred"></div></td>
</tr>
<tr>
<td colspan="2"><strong>Search Location: </strong>&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" id="geoCityName" value="${cityName}" size="60" class="reg_text_box" style="width:372px;height:20px;border:2px solid #ccc" />&nbsp;				
<img src="${cdnPath}/images/courtmgm/search.gif" style="cursor: pointer;border:0; vertical-align:middle" onclick="searchAddress()" />&nbsp;&nbsp;&nbsp;<div id="suggest"></div>
</td>
<script type="text/javascript">
var geoCityName = $('#geoCityName');
geoCityName.autocomplete('/ajax/cityNameLatLongList.htm', { minChars:2, max:100, cacheLength:100, matchContains:true, autoFill:false, selectFirst:false });		
geoCityName.result(function(event, data, formatted) {
//alert(data);
$('#geoCityName').val(data[0]);
$('#cityName').val(data[0]);
$('#latitude').val(data[2]);
$('#longitude').val(data[3]);
});
</script>	
</tr>
<tr>
<td colspan="2" style="padding-bottom:5px;padding-top:5px;border-bottom:1px solid #ccc"><strong>Geo Location:</strong>&nbsp;
<input type="text" id="longitude" size="10" class="reg_text_box" disabled="disabled" style="width:140px;height:18px" value="" />&nbsp;
<input type="text" id="latitude" size="10" class="reg_text_box" disabled="disabled" style="width:140px;height:18px" value="" />&nbsp;
<input type="image" src="${cdnPath}/images/courtmgm/finished.gif" onclick="validateVerifyLocForm()" border="0" style="vertical-align:middle" />

&nbsp;<a href="${conf.TE_HOME}/club/${club.shortName}" style="text-decoration:underline">Go to Club Home</a>	
<!--<input name="Submit" type="button" value="Create Club" class="btnblue" onclick="validateVerifyLocForm()" style="padding:2px 4px 5px 6px;font-size:12px;cursor:pointer;" />-->
</td>
</tr>
<tr>
<td colspan="2" style="padding-bottom:4px">
<table border="0" width="100%">
<tr>
<td colspan="2">
<div id="messageLocationsubmit" class="textred"></div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2"><span style="font-size:12px;">Search for your address and drag the marker to your location. Else <strong>Right click</strong> to place it at a point.</span></td>
</tr>

<tr>
<td style="width:450px;">
<div id="map" style="height:500px;overflow:hidden"></div>
<ul id="mapContextMenu">
<c:set var="placeMarker" value="Place Marker Here" />
<c:if test="${not empty selAddress}">
<c:set var="placeMarker" value="Move Location Here" />
</c:if>
<li><a href="#placeMarker">${placeMarker}</a></li>
</ul>
</td>
<td valign="top" style="text-decoration:underline;color:#4444ff;width:120px;">
<div style="overflow:auto;height:500px;text-decoration:none;">
<table id="map_sidebar" border="0" width="100%"></table>
</div>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</div>
<c:if test="${sessionScope.loginEntity == 'Create Tournament'}">
<script type="text/javascript">
var loginEntityName = $("#loginEntityName").val();
$("#tournamentName").val(loginEntityName.toLowerCase());
createTournament();
</script>
</c:if>
<!-- ***********************************      Geo Location Div Ends     ***********************************     --> 		

</div>
</div>
<!--Anonymized entity footer-->
</div></div>


<%-- <jsp:include page="/footerNew.htm" /> --%>
<%session.removeAttribute("loginEntity");%>
<%session.removeAttribute("loginEntityName");%>

